<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>buttontester.cpp 示例文件 | Qt Widgets 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-widgets-mousebuttons-example.html">Mouse Button Tester</a></td><td >buttontester.cpp 示例文件</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">buttontester.cpp 示例文件</h1>
<span class="subtitle">widgets/mousebuttons/buttontester.cpp</span>
<!-- $$$widgets/mousebuttons/buttontester.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp">

  <span class="comment">/****************************************************************************
  **
  ** Copyright (C) 2016 The Qt Company Ltd.
  ** Copyright (C) 2016 Rick Stockton &lt;rickstockton@reno-computerhelp.com&gt;
  ** Contact: https://www.qt.io/licensing/
  **
  ** This file is part of the examples of the Qt Toolkit.
  **
  ** $QT_BEGIN_LICENSE:BSD$
  ** Commercial License Usage
  ** Licensees holding valid commercial Qt licenses may use this file in
  ** accordance with the commercial license agreement provided with the
  ** Software or, alternatively, in accordance with the terms contained in
  ** a written agreement between you and The Qt Company. For licensing terms
  ** and conditions see https://www.qt.io/terms-conditions. For further
  ** information use the contact form at https://www.qt.io/contact-us.
  **
  ** BSD License Usage
  ** Alternatively, you may use this file under the terms of the BSD license
  ** as follows:
  **
  ** &quot;Redistribution and use in source and binary forms, with or without
  ** modification, are permitted provided that the following conditions are
  ** met:
  **   * Redistributions of source code must retain the above copyright
  **     notice, this list of conditions and the following disclaimer.
  **   * Redistributions in binary form must reproduce the above copyright
  **     notice, this list of conditions and the following disclaimer in
  **     the documentation and/or other materials provided with the
  **     distribution.
  **   * Neither the name of The Qt Company Ltd nor the names of its
  **     contributors may be used to endorse or promote products derived
  **     from this software without specific prior written permission.
  **
  **
  ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  ** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
  **
  ** $QT_END_LICENSE$
  **
  ****************************************************************************/</span>

  <span class="preprocessor">#include &quot;buttontester.h&quot;</span>

  <span class="preprocessor">#include &lt;QDebug&gt;</span>

  <span class="type">void</span> ButtonTester<span class="operator">::</span>mousePressEvent(<span class="type"><a href="../qtgui/qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>e)
  {
      <span class="type">int</span> j <span class="operator">=</span> ButtonTester<span class="operator">::</span>buttonByNumber (e<span class="operator">-</span><span class="operator">&gt;</span>button());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> result <span class="operator">=</span> <span class="string">&quot;Mouse Press: raw button=&quot;</span> <span class="operator">+</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span><span class="operator">::</span>number(j)
                  <span class="operator">+</span> <span class="string">&quot;  Qt=&quot;</span> <span class="operator">+</span> enumNameFromValue(e<span class="operator">-</span><span class="operator">&gt;</span>button());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> buttonsString <span class="operator">=</span> ButtonTester<span class="operator">::</span>enumNamesFromMouseButtons(e<span class="operator">-</span><span class="operator">&gt;</span>buttons());
      result <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;\n heldbuttons &quot;</span> <span class="operator">+</span> buttonsString;
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> result;
      <span class="keyword">this</span><span class="operator">-</span><span class="operator">&gt;</span>setText(result);
      <span class="keyword">this</span><span class="operator">-</span><span class="operator">&gt;</span>repaint();
  }

  <span class="type">void</span> ButtonTester<span class="operator">::</span>mouseReleaseEvent(<span class="type"><a href="../qtgui/qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>e)
  {
      <span class="type">int</span> j <span class="operator">=</span> ButtonTester<span class="operator">::</span>buttonByNumber (e<span class="operator">-</span><span class="operator">&gt;</span>button());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> result <span class="operator">=</span> <span class="string">&quot;Mouse Release: raw button=&quot;</span> <span class="operator">+</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span><span class="operator">::</span>number(j)
                  <span class="operator">+</span> <span class="string">&quot;  Qt=&quot;</span> <span class="operator">+</span> enumNameFromValue(e<span class="operator">-</span><span class="operator">&gt;</span>button());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> buttonsString <span class="operator">=</span> ButtonTester<span class="operator">::</span>enumNamesFromMouseButtons(e<span class="operator">-</span><span class="operator">&gt;</span>buttons());
      result <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;\n heldbuttons &quot;</span> <span class="operator">+</span> buttonsString;
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> result;
      <span class="keyword">this</span><span class="operator">-</span><span class="operator">&gt;</span>setText(result);
      <span class="keyword">this</span><span class="operator">-</span><span class="operator">&gt;</span>repaint();

  }

  <span class="type">void</span> ButtonTester<span class="operator">::</span>mouseDoubleClickEvent(<span class="type"><a href="../qtgui/qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>e)
  {
      <span class="type">int</span> j <span class="operator">=</span> ButtonTester<span class="operator">::</span>buttonByNumber (e<span class="operator">-</span><span class="operator">&gt;</span>button());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> result <span class="operator">=</span> <span class="string">&quot;Mouse DoubleClick: raw button=&quot;</span> <span class="operator">+</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span><span class="operator">::</span>number(j)
                  <span class="operator">+</span> <span class="string">&quot;  Qt=&quot;</span> <span class="operator">+</span> enumNameFromValue(e<span class="operator">-</span><span class="operator">&gt;</span>button());
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> buttonsString <span class="operator">=</span> ButtonTester<span class="operator">::</span>enumNamesFromMouseButtons(e<span class="operator">-</span><span class="operator">&gt;</span>buttons());
      result <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;\n heldbuttons&quot;</span> <span class="operator">+</span> buttonsString;
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> result;
      <span class="keyword">this</span><span class="operator">-</span><span class="operator">&gt;</span>setText(result);
  }

  <span class="preprocessor">#if QT_CONFIG(wheelevent)</span>
  <span class="type">void</span> ButtonTester<span class="operator">::</span>wheelEvent (<span class="type"><a href="../qtgui/qwheelevent.html">QWheelEvent</a></span> <span class="operator">*</span>e)
  {
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> result;
      <span class="keyword">if</span> (e<span class="operator">-</span><span class="operator">&gt;</span>delta() <span class="operator">&gt;</span> <span class="number">0</span>) {

          <span class="keyword">if</span> (e<span class="operator">-</span><span class="operator">&gt;</span>orientation() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>Vertical) {
              result <span class="operator">=</span> <span class="string">&quot;Mouse Wheel Event: UP&quot;</span>;
          } <span class="keyword">else</span> {
              result <span class="operator">=</span> <span class="string">&quot;Mouse Wheel Event: LEFT&quot;</span>;
          }
      } <span class="keyword">else</span> <span class="keyword">if</span> (e<span class="operator">-</span><span class="operator">&gt;</span>delta() <span class="operator">&lt;</span> <span class="number">0</span>) {
          <span class="keyword">if</span> (e<span class="operator">-</span><span class="operator">&gt;</span>orientation() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>Vertical) {
              result <span class="operator">=</span> <span class="string">&quot;Mouse Wheel Event: DOWN&quot;</span>;
          } <span class="keyword">else</span> {
              result <span class="operator">=</span> <span class="string">&quot;Mouse Wheel Event: RIGHT&quot;</span>;
          }
      }
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> result;
      <span class="keyword">this</span><span class="operator">-</span><span class="operator">&gt;</span>setText(result);
  }
  <span class="preprocessor">#endif</span>

  <span class="type">int</span> ButtonTester<span class="operator">::</span>buttonByNumber(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>MouseButton button)
  {
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>NoButton)      <span class="keyword">return</span> <span class="number">0</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>LeftButton)    <span class="keyword">return</span> <span class="number">1</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>RightButton)   <span class="keyword">return</span> <span class="number">2</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>MiddleButton)  <span class="keyword">return</span> <span class="number">3</span>;

  <span class="comment">/* Please note that Qt Button #4 corresponds to button #8 on all
   * platforms which EMULATE wheel events by creating button events
   * (Button #4 = Scroll Up; Button #5 = Scroll Down; Button #6 = Scroll
   * Left; and Button #7 = Scroll Right.) This includes X11, with both
   * Xlib and XCB.  So, the &quot;raw button&quot; for &quot;Qt::BackButton&quot; is
   * usually described as &quot;Button #8&quot;.

   * If your platform supports &quot;smooth scrolling&quot;, then, for the cases of
   * Qt::BackButton and higher, this program will show &quot;raw button&quot; with a
   * value which is too large. Subtract 4 to get the correct button ID for
   * your platform.
   */</span>

      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>BackButton)    <span class="keyword">return</span> <span class="number">8</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ForwardButton) <span class="keyword">return</span> <span class="number">9</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>TaskButton)    <span class="keyword">return</span> <span class="number">10</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton4)  <span class="keyword">return</span> <span class="number">11</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton5)  <span class="keyword">return</span> <span class="number">12</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton6)  <span class="keyword">return</span> <span class="number">13</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton7)  <span class="keyword">return</span> <span class="number">14</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton8)  <span class="keyword">return</span> <span class="number">15</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton9)  <span class="keyword">return</span> <span class="number">16</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton10) <span class="keyword">return</span> <span class="number">17</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton11) <span class="keyword">return</span> <span class="number">18</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton12) <span class="keyword">return</span> <span class="number">19</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton13) <span class="keyword">return</span> <span class="number">20</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton14) <span class="keyword">return</span> <span class="number">21</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton15) <span class="keyword">return</span> <span class="number">22</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton16) <span class="keyword">return</span> <span class="number">23</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton17) <span class="keyword">return</span> <span class="number">24</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton18) <span class="keyword">return</span> <span class="number">25</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton19) <span class="keyword">return</span> <span class="number">26</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton20) <span class="keyword">return</span> <span class="number">27</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton21) <span class="keyword">return</span> <span class="number">28</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton22) <span class="keyword">return</span> <span class="number">29</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton23) <span class="keyword">return</span> <span class="number">30</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton24) <span class="keyword">return</span> <span class="number">31</span>;
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value&quot;</span>);
      <span class="keyword">return</span> <span class="number">0</span>;
  }

  <span class="type"><a href="../qtcore/qstring.html">QString</a></span> ButtonTester<span class="operator">::</span>enumNameFromValue(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>MouseButton button)
  {
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>NoButton)      <span class="keyword">return</span> <span class="string">&quot;NoButton&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>LeftButton)    <span class="keyword">return</span> <span class="string">&quot;LeftButton&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>RightButton)   <span class="keyword">return</span> <span class="string">&quot;RightButton&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>MiddleButton)  <span class="keyword">return</span> <span class="string">&quot;MiddleButton&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>BackButton)    <span class="keyword">return</span> <span class="string">&quot;BackButton&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ForwardButton) <span class="keyword">return</span> <span class="string">&quot;ForwardButton&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>TaskButton)    <span class="keyword">return</span> <span class="string">&quot;TaskButton&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton4)  <span class="keyword">return</span> <span class="string">&quot;ExtraButton4&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton5)  <span class="keyword">return</span> <span class="string">&quot;ExtraButton5&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton6)  <span class="keyword">return</span> <span class="string">&quot;ExtraButton6&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton7)  <span class="keyword">return</span> <span class="string">&quot;ExtraButton7&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton8)  <span class="keyword">return</span> <span class="string">&quot;ExtraButton8&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton9)  <span class="keyword">return</span> <span class="string">&quot;ExtraButton9&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton10) <span class="keyword">return</span> <span class="string">&quot;ExtraButton10&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton11) <span class="keyword">return</span> <span class="string">&quot;ExtraButton11&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton12) <span class="keyword">return</span> <span class="string">&quot;ExtraButton12&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton13) <span class="keyword">return</span> <span class="string">&quot;ExtraButton13&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton14) <span class="keyword">return</span> <span class="string">&quot;ExtraButton14&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton15) <span class="keyword">return</span> <span class="string">&quot;ExtraButton15&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton16) <span class="keyword">return</span> <span class="string">&quot;ExtraButton16&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton17) <span class="keyword">return</span> <span class="string">&quot;ExtraButton17&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton18) <span class="keyword">return</span> <span class="string">&quot;ExtraButton18&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton19) <span class="keyword">return</span> <span class="string">&quot;ExtraButton19&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton20) <span class="keyword">return</span> <span class="string">&quot;ExtraButton20&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton21) <span class="keyword">return</span> <span class="string">&quot;ExtraButton21&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton22) <span class="keyword">return</span> <span class="string">&quot;ExtraButton22&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton23) <span class="keyword">return</span> <span class="string">&quot;ExtraButton23&quot;</span>;
      <span class="keyword">if</span> (button <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton24) <span class="keyword">return</span> <span class="string">&quot;ExtraButton24&quot;</span>;
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value&quot;</span>);
      <span class="keyword">return</span> <span class="string">&quot;NoButton&quot;</span>;
  }

  <span class="type"><a href="../qtcore/qstring.html">QString</a></span> ButtonTester<span class="operator">::</span>enumNamesFromMouseButtons(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>MouseButtons buttons)
  {
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> returnText <span class="operator">=</span> <span class="string">&quot;&quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>NoButton)      <span class="keyword">return</span> <span class="string">&quot;NoButton&quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>LeftButton)    returnText <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;LeftButton &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>RightButton)   returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;RightButton &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>MiddleButton)  returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;MiddleButton &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>BackButton)    returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;BackButton &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ForwardButton) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ForwardButton &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>TaskButton)    returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;TaskButton &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton4)  returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton4 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton5)  returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton5 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton6)  returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton6 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton7)  returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton7 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton8)  returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton8 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton9)  returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton9 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton10) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton10 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton11) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton11 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton12) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton12 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton13) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton13 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton14) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton14 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton15) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton15 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton16) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton16 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton17) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton17 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton18) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton18 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton19) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton19 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton20) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton20 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton21) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton21 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton22) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton22 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton23) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton23 &quot;</span>;
      <span class="keyword">if</span> (buttons <span class="operator">&amp;</span> <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ExtraButton24) returnText <span class="operator">+</span><span class="operator">=</span>  <span class="string">&quot;ExtraButton24 &quot;</span>;
      <span class="keyword">return</span> returnText;
  }

</pre>
</div>
<!-- @@@widgets/mousebuttons/buttontester.cpp -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
